<?php
/**
 *    @version [ Masterton ]
 *    @package hwdVideoShare
 *    @copyright (C) 2007 - 2009 Highwood Design
 *    @license Creative Commons Attribution-Non-Commercial-No Derivative Works 3.0 Unported Licence
 *    @license http://creativecommons.org/licenses/by-nc-nd/3.0/
 */
defined( '_JEXEC' ) or die( 'Direct Access to this location is not allowed.' );

global $mainframe, $Itemid, $option, $task;

if (!file_exists(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS)) {
	echo "<div style=\"border:1px solid #c30;color:#c30;margin: 0 0 5px 0;padding: 5px;font-weight: bold;text-align:left;text-align:center;\">The hwdVideoShare component is not installed, you can not use this module.</div>"; return;
}

if (@_HWD_VS_PLUGIN_COMPS !== 214) {
	echo "<div style=\"border:1px solid #c30;color:#c30;margin: 0 0 5px 0;padding: 5px;font-weight: bold;text-align:left;text-align:center;\">This module is not compatible with your version of hwdVideoShare.</div>"; return;
}

$db =& JFactory::getDBO();
$my = & JFactory::getUser();

$db->SetQuery( "SELECT count(*) FROM #__hwdvidsvideos" );
$stats['totalvideos'] = $db->loadResult();

$db->SetQuery( "SELECT count(*) FROM #__users" );
$stats['totalusers'] = $db->loadResult();

$db->SetQuery( "SELECT count(*) FROM #__hwdvidsvideos WHERE date_uploaded >= DATE_SUB(NOW(),INTERVAL 7 DAY)" );
$stats['totalvideosweek'] = $db->loadResult();

$db->SetQuery( "SELECT count(*) FROM #__hwdvidslogs_views" );
$views_30 = $db->loadResult();
$db->SetQuery( "SELECT SUM(views) FROM #__hwdvidslogs_archive" );
$views_all = $db->loadResult();
$stats['totalviews'] = $views_30 + $views_all;

//$db->setQuery( "SELECT count(*) FROM #__hwdvidsvideos WHERE approved = \"pending\"" );
//$stats['approvals'] = $db->loadResult();

//$db->SetQuery( "SELECT count(*) FROM #__hwdvidsvideos WHERE approved = \"queuedforconversion\" AND approved = \"queuedforthumbnail\"" );
//$stats['conversion'] = $db->loadResult();

//$db->SetQuery( "SELECT count(*) FROM #__hwdvidsflagged_videos WHERE status = \"UNREAD\"" );
//$stats['reportedvideos'] = $db->loadResult();

//$db->SetQuery( "SELECT count(*) FROM #__hwdvidsflagged_groups WHERE status = \"UNREAD\"" );
//$stats['reportedgroups'] = $db->loadResult();

//$db->SetQuery( "SELECT count(*) FROM #__hwdvidscategories" );
//$stats['totalcategories'] = $db->loadResult();

//$db->SetQuery( "SELECT id FROM #__users ORDER BY registerDate DESC" );
//$stats['latestuser'] = hwd_vs_tools::generateBEUserFromID($db->loadResult());

//$db->SetQuery( "SELECT count(*) FROM #__hwdvidsgroups" );
//$stats['totalgroups'] = $db->loadResult();

//$db->SetQuery( "SELECT id, group_name FROM #__hwdvidsgroups ORDER BY date DESC" );
//$latestgroup = $db->loadObject();
//if (!empty($latestgroup->id)) { $stats['latestgroup'] = "<a href=\"index.php?option=com_hwdvideoshare&task=editgrpA&hidemainmenu=1&cid=".$latestgroup->id."\">$latestgroup->group_name</a>"; } else { $stats['latestgroup']=null; }

//$db->SetQuery( "SELECT count(*) FROM #__hwdvidsvideos WHERE date_uploaded >= DATE_SUB(NOW(),INTERVAL 1 DAY)" );
//$stats['totalvideostoday'] = $db->loadResult();

//$db->SetQuery( "SELECT count(*) FROM #__hwdvidslogs_favours" );
//$favours_30 = $db->loadResult();
//$db->SetQuery( "SELECT SUM(favours) FROM #__hwdvidslogs_archive" );
//$favours_all = $db->loadResult();
//$stats['totalfavours'] = $favours_30 + $favours_all;

$code = "Currently hosting ".$stats['totalvideos']." videos. Serving ".$stats['totalvideos']." video views for ".$stats['totalusers']." users.";
//$code = $stats['totalusers']." users have watched ".$stats['totalvideos']." videos, ".$stats['totalviews']." times, with ".$stats['totalvideosweek']." new videos added this week.";

echo $code;

return;
?>




